package com.fessc.develop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fessc.develop.entity.comvo.BankCheckFileApplyVo;
import com.fessc.develop.entity.dbvo.TCheckResult;
import com.fessc.develop.mapper.TCheckResultMapper;
import com.fessc.develop.service.interfaces.ITCheckResultService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fessc.develop.utils.BusiUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author y
 * @since 2024-07-16
 */
@Service
public class TCheckResultServiceImpl extends ServiceImpl<TCheckResultMapper, TCheckResult> implements ITCheckResultService {

    @Resource
    private TCheckResultMapper checkResultMapper;

    /**
     * 根据对账日期，查询待申请对账文件记录
     *
     * @param bankId  银行编号
     * @param checkDate 对账时间
     * @return list
     */
    @Override
    public List<BankCheckFileApplyVo> getBankCheckApplyListByDate(String bankId, Date checkDate) {
        return checkResultMapper.getBankCheckApplyListByDate(bankId, checkDate);
    }

    /**
     * 根据对账日期，查询待下载对账文件记录
     *
     * @param checkDate 对账时间
     * @param applyStatus  申请状态
     * @param downStatus 下载状态
     * @return list
     */
    @Override
    public List<TCheckResult> getBankCheckDownListByDate(String bankId, Date checkDate, String applyStatus, String downStatus) {
        QueryWrapper<TCheckResult> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("check_date", checkDate);
        if (BusiUtil.isNotNull(applyStatus)) {
            queryWrapper.eq("apply_status", applyStatus);
        }
        if (BusiUtil.isNotNull(downStatus)) {
            queryWrapper.ne("down_status", downStatus);
        }
        if (BusiUtil.isNotNull(bankId)) {
            queryWrapper.ne("bank_id", bankId);
        }
        return this.list(queryWrapper);
    }

}
